section .text
	global strncmp

strncmp:
	xor rax, rax
	jmp .comp

.negatif:
	sub cl, bl
	mov al, cl
	neg rax
	jmp .endcmp

.positif:
	sub bl, cl
	mov al, bl
	jmp .endcmp

.same:
	mov rax, 0
	jmp .endcmp

.loop:
	inc rdi
	inc rsi
	dec rdx

.comp:
	cmp rdx, 0
	je .endcmp
	mov bl, byte [rdi]
	mov cl, byte [rsi]
	cmp bl, cl
	jb .negatif
	jg .positif
	cmp bl, 0
	je .same
	jmp .loop

.endcmp:
	ret